package com.hk.Mgr.web.controller;

import com.hk.commons.entity.product.Payment;
import com.hk.service.order.IPayment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hk.base.ResponseBase;
import com.hk.commons.CreateUniqueTokensUtil;
import com.hk.commons.ResultCode;

@Controller
public class GetTokenCtrl {

	private Logger logger = LoggerFactory.getLogger(GetTokenCtrl.class);

	@ResponseBody
	@RequestMapping(value = "/getTokenRandom", method = RequestMethod.GET)
	public ResponseBase<String> payValidate(@RequestParam String userId) {
		logger.info("will start to get token userId={}", userId);
		userId = userId.split(",")[0];
		ResponseBase<String> base = new ResponseBase<String>();
		String token = CreateUniqueTokensUtil.getRandomToken(userId);
		base.setMsg("获取token成功");
		base.setResult(token);
		base.setResultCode(ResultCode.SUCC.getCode());
		logger.info("will end to get token userId={}, token={}", userId, token);
		return base;
	}
}
